package com.nbsaas.boot.merchant.rest.resource;

import com.nbsaas.boot.merchant.api.apis.MerchantApi;
import com.nbsaas.boot.merchant.data.entity.Merchant;
import com.nbsaas.boot.merchant.api.domain.request.MerchantRequest;
import com.nbsaas.boot.merchant.api.domain.response.MerchantResponse;
import com.nbsaas.boot.merchant.api.domain.simple.MerchantSimple;
import com.nbsaas.boot.merchant.rest.convert.MerchantSimpleConvert;
import com.nbsaas.boot.merchant.rest.convert.MerchantEntityConvert;
import com.nbsaas.boot.merchant.rest.convert.MerchantResponseConvert;
import com.nbsaas.boot.merchant.data.repository.MerchantRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   商家-业务接口实现
*/
@Transactional
@Service
public class MerchantResource extends BaseResource<Merchant,MerchantResponse, MerchantSimple, MerchantRequest>  implements MerchantApi {

    @Resource
    private MerchantRepository merchantRepository;

    @Override
    public JpaRepositoryImplementation<Merchant, Serializable> getJpaRepository() {
        return merchantRepository;
    }

    @Override
    public Function<Merchant, MerchantSimple> getConvertSimple() {
        return new MerchantSimpleConvert();
    }

    @Override
    public Function<MerchantRequest, Merchant> getConvertForm() {
        return new MerchantEntityConvert();
    }

    @Override
    public Function<Merchant, MerchantResponse> getConvertResponse() {
        return new MerchantResponseConvert();
    }




}


